﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using wfDesigner.Model;
using Microhard.WorkflowDataAccess;

namespace wfDesigner
{
    /// <summary>
    /// AddFlowTypeWindow.xaml 的交互逻辑
    /// </summary>
    public partial class AddFlowTypeWindow : Window
    {
        public AddFlowTypeWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            this.DataTimeTxt.Text = System.DateTime.Now.ToString("yyyy-MM-dd");
        }

        private void AddBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                WorkflowDBDataContext entity = new WorkflowDBDataContext();
                t_WorkFlowType ft = new t_WorkFlowType();
                ft.TypeId = Guid.NewGuid();
                ft.TypeName = this.TypeNameTxt.Text;
                ft.TypeRemark = this.RemarkTxt.Text;
                ft.CreateDate = Convert.ToDateTime(this.DataTimeTxt.Text);

                entity.t_WorkFlowTypes.InsertOnSubmit(ft);
                entity.SubmitChanges();
            }
            catch
            {
                MessageBox.Show("添加失败！", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                this.Close();
            }
        }

        private void CancelBtn_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
